package com.zzy.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzy.demo.dao.SchoolDao;
import com.zzy.demo.model.School;
import com.zzy.demo.service.SchoolService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SchoolServiceImpl extends ServiceImpl<SchoolDao, School> implements SchoolService {

    @Override
    public School getSchoolById(int id) {
        return baseMapper.selectById(id);
    }

    @Override
    public Page<School> getByPage() {
        Page<School> page =new Page<>(1,5);

        Wrapper<School> wrapper = Wrappers.lambdaQuery();
        baseMapper.selectPage(page, wrapper);
        List<School> list = page.getRecords();

        System.out.println("===============================" + list.size());
        //获取总数
        page.getTotal();
        return page;
    }

}

